package com.algorithm.fifty2onehundred;

/**
 * @author tuzhijin
 * @version Id: ClimbStairs_70.java, v 0.1 2021/5/23 上午11:41 tuzhijin Exp $$
 */
public class ClimbStairs_70 {

    public static void main(String[] args) {
        System.out.println(climbStairs(3));
    }

    public static int climbStairs(int n) {
        int p, q = 0, r = 1;
        // f(n)=f(n-1)+f(n-2)
        for (int i = 0; i < n; i++) {
            p = q;
            q = r;
            r = p + q;
        }
        return r;
    }

}
